package bb.lanxing.model.database;

import android.os.Parcel;
import android.os.Parcelable;
//import com.orm.SugarRecord;
import com.orm.dsl.Ignore;
//import com.orm.dsl.Table;
//import com.orm.query.Select;
import bb.lanxing.util.JsonUtil;
import java.util.List;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import org.litepal.LitePal;
import org.litepal.crud.LitePalSupport;


public class MapsBean extends LitePalTableBase implements Parcelable {
    static final /* synthetic */ boolean $assertionsDisabled = false;
    public static final Parcelable.Creator<MapsBean> CREATOR = new Parcelable.Creator<MapsBean>() { //

        public MapsBean createFromParcel(Parcel parcel) {
            return new MapsBean(parcel);
        }


        public MapsBean[] newArray(int i) {
            return new MapsBean[i];
        }
    };
    @Ignore
    private List<MapItem> classic;
    private String classicName;
    @Ignore
    private List<MapItem> pro;
    private String proName;

    @Override
    public int describeContents() {
        return 0;
    }

    public MapsBean() {
    }

    public MapsBean(JSONObject jSONObject) {
        JSONObject objectValue = JsonUtil.getObjectValue("pro", jSONObject);
        JSONObject objectValue2 = JsonUtil.getObjectValue("classic", jSONObject);
        setProName(JsonUtil.getStringValue("name", objectValue));
        JSONArray arrayValue = JsonUtil.getArrayValue("items", objectValue);
        MapItem.deleteAll(MapItem.class);
        for (int i = 0; i < arrayValue.length(); i++) {
            try {
                new MapItem(arrayValue.getJSONObject(i)).save();
            } catch (JSONException e) {
                e.printStackTrace();
            }
        }
        setClassicName(JsonUtil.getStringValue("name", objectValue2));
        JSONArray arrayValue2 = JsonUtil.getArrayValue("items", objectValue2);
        for (int i2 = 0; i2 < arrayValue2.length(); i2++) {
            try {
                new MapItem(arrayValue2.getJSONObject(i2)).save();
            } catch (JSONException e2) {
                e2.printStackTrace();
            }
        }
    }

    public static MapsBean getById(long j) {

        String id = String.valueOf(j);

        MapsBean m = LitePal.where("baseObjId=?", id).findFirst(MapsBean.class);
        return m;


//        return (MapsBean) Select.from(MapsBean.class).where(" id = ?", new String[]{String.valueOf(j)}).first();
    }

    protected MapsBean(Parcel parcel) {
        this.pro = parcel.createTypedArrayList(MapItem.CREATOR);
        this.proName = parcel.readString();
        this.classic = parcel.createTypedArrayList(MapItem.CREATOR);
        this.classicName = parcel.readString();
    }

    @Override
    public void writeToParcel(Parcel parcel, int i) {
        parcel.writeTypedList(this.pro);
        parcel.writeString(this.proName);
        parcel.writeTypedList(this.classic);
        parcel.writeString(this.classicName);
    }

    public List<MapItem> getPro() {
        if (this.pro == null) {
            this.pro = MapItem.getByMapType("pro");
        }
        return this.pro;
    }

    public void setPro(List<MapItem> list) {
        this.pro = list;
    }

    public String getProName() {
        return this.proName;
    }

    public void setProName(String str) {
        this.proName = str;
    }

    public List<MapItem> getClassic() {
        if (this.classic == null) {
            this.classic = MapItem.getByMapType("classic");
        }
        return this.classic;
    }

    public void setClassic(List<MapItem> list) {
        this.classic = list;
    }

    public String getClassicName() {
        return this.classicName;
    }

    public void setClassicName(String str) {
        this.classicName = str;
    }
}
